package com.tudouji.project.mt.service.impl;

import java.util.List;
import com.tudouji.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.tudouji.project.mt.mapper.MtGoodsDueMapper;
import com.tudouji.project.mt.domain.MtGoodsDue;
import com.tudouji.project.mt.service.IMtGoodsDueService;

/**
 * 美团替代料对应关系Service业务层处理
 * 
 * @author tudouji
 * @date 2024-02-21
 */
@Service
public class MtGoodsDueServiceImpl implements IMtGoodsDueService 
{
    @Autowired
    private MtGoodsDueMapper mtGoodsDueMapper;

    /**
     * 查询美团替代料对应关系
     * 
     * @param id 美团替代料对应关系ID
     * @return 美团替代料对应关系
     */
    @Override
    public MtGoodsDue selectMtGoodsDueById(Long id)
    {
        return mtGoodsDueMapper.selectMtGoodsDueById(id);
    }

    /**
     * 查询美团替代料对应关系列表
     * 
     * @param mtGoodsDue 美团替代料对应关系
     * @return 美团替代料对应关系
     */
    @Override
    public List<MtGoodsDue> selectMtGoodsDueList(MtGoodsDue mtGoodsDue)
    {
        return mtGoodsDueMapper.selectMtGoodsDueList(mtGoodsDue);
    }

    /**
     * 新增美团替代料对应关系
     * 
     * @param mtGoodsDue 美团替代料对应关系
     * @return 结果
     */
    @Override
    public int insertMtGoodsDue(MtGoodsDue mtGoodsDue)
    {
        mtGoodsDue.setCreateTime(DateUtils.getNowDate());
        return mtGoodsDueMapper.insertMtGoodsDue(mtGoodsDue);
    }

    /**
     * 修改美团替代料对应关系
     * 
     * @param mtGoodsDue 美团替代料对应关系
     * @return 结果
     */
    @Override
    public int updateMtGoodsDue(MtGoodsDue mtGoodsDue)
    {
        mtGoodsDue.setUpdateTime(DateUtils.getNowDate());
        return mtGoodsDueMapper.updateMtGoodsDue(mtGoodsDue);
    }

    /**
     * 批量删除美团替代料对应关系
     * 
     * @param ids 需要删除的美团替代料对应关系ID
     * @return 结果
     */
    @Override
    public int deleteMtGoodsDueByIds(Long[] ids)
    {
        return mtGoodsDueMapper.deleteMtGoodsDueByIds(ids);
    }

    /**
     * 删除美团替代料对应关系信息
     * 
     * @param id 美团替代料对应关系ID
     * @return 结果
     */
    @Override
    public int deleteMtGoodsDueById(Long id)
    {
        return mtGoodsDueMapper.deleteMtGoodsDueById(id);
    }

    @Override
    public boolean exist(String mtGoodsCode, String mtGoodsCodeDue){
        MtGoodsDue mtGoodsDue = new MtGoodsDue();
        mtGoodsDue.setMtGoodsCode(mtGoodsCode);
        mtGoodsDue.setMtGoodsCodeDue(mtGoodsCodeDue);
        List<MtGoodsDue> goodsDueList = mtGoodsDueMapper.selectMtGoodsDueList(mtGoodsDue);
        if (goodsDueList.size() > 0){
            return false;
        }
        return true;
    }
}
